|
|
|
| ' Set Salaries for Employees
gacurSalary(0) = 100000
gacurSalary(1) = 150000
gacurSalary(2) = 60000
gacurSalary(3) = 90000
' Retrieve SSNs, Names & Salaries
Me.Cls
Me.Print gastrSSN(0), gastrNames(0), gacurSalary(0)
Me.Print gastrSSN(1), gastrNames(1), gacurSalary(1)
Me.Print gastrSSN(2), gastrNames(2), gacurSalary(2)
Me.Print gastrSSN(3), gastrNames(3), gacurSalary(3)
End Sub |  | This example assigns employee Social Security numbers to each element of the gastrSSN array. Next, employee names are assigned to each element of the gastrNames array. Finally, a salary is assigned for each employee to each element of the gacurSalary array. Once the values are in the array, the Me.Cls command is used to clear the form and then the Me.Print method of the form is used to display the values on the form area. The results are shown in Figure 7.2. | | | | |
|
|
|
|
Figure 7.2
Fixed-size arrays. |
|
|
|
|
|
|
|
|
|
|
It does not matter whether the array was public, module level, or local, the assignment statements and the print statements are all the same. Whats important is that the type of data you can put into the array depends on how you declare that array. Arrays can be declared as type Variant, which means each element of the array can store a different data type. Youll see an example of this later in the chapter. |
|
|
|
|
|